console.log("hello javascript");

var a = "10086"
a = parseInt(a)  // 变成整数
console.log(a + 10);   // 10096

var b = 100;
var c = a.toString(); // 变成字符串
var c = a + "001";
console.log(c);     // 10086001

var m = 122;
var n = m.toString(16); // 将m转化为16进制
console.log(n);

var p = parseInt("AB", 16);
console.log(p);     // 171

var box1 = 1 + true;
console.log(box1);    // 2

// 字符串
var str = "广东-深圳-南山"
let ret = str.split('-')
console.log(ret);   // [ '广东', '深圳', '南山' ]

var s = "hello world"
var res = s.substr(0, 3)
console.log(res);     // hel

var password = "          Mrs     alen   "
var t = password.trim();
console.log(t);   // Mrs     alen

console.log(password.length);   // 25

var word = "hello world";      // [3,6)
var w = word.slice(3, 6) // 切片
console.log(w)    // lo

var w1 = word.slice(2, -1)
console.log(w1)   // llo worl

var e = "hello Alen "
res = e.substring(1, 6)
console.log(res);   // ello
console.log(e.charAt(0));  // h
console.log(e.charAt(0).toUpperCase());  // H
console.log(e.charAt(6).toLowerCase());  // a
console.log(e.indexOf(2));   // -1
console.log(e.indexOf('e')); // 1

console.log(e.charCodeAt(6));  //  65
console.log(String.fromCharCode(65));  // A

var a = e.charAt(6).toLowerCase();
console.log(a.charCodeAt(0));  // 97
console.log(typeof a);   // string

// 正则表达式主体/修饰符(可选)
var tr = "我的电话是: 13151567403，你的电话是: 13987465201"
var result = tr.match(/\d{11}/g);    //  g => global
console.log(result); //

var phone = "我的电话是: 15309843931"
var re = phone.replace(/(\d{3})\d{4}(\d{4})/, "$1****$2")   // 正则的捕获模式 $1 $2 表示正则中第一个和第二个小括号捕获的内容
console.log(re);  // 我的电话是: 153****3931

var global = "hello"
var r1 = global.search(/j/);
var r2 = global.search(/e/);
console.log(r1);    // -1
console.log(r2);    // 1

var alen
console.log(alen);  // undefined

var m = "javascript"
var b = m;
m = "python"
console.log(m);  // python
console.log(b);  // javascript

var arr1 = [1,2];
var arr2 = arr1;
arr1.push(3)
console.log(arr1);  // [ 1, 2, 3 ]
console.log(arr2);  // [ 1, 2, 3 ]

arr1 = [4,5]
console.log(arr1)  //  [ 4, 5 ]
console.log(arr2)  //  [ 1, 2, 3 ]
